package com.zpark.controller.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class GlobalExceptionHandlerController {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Map<String,Object> handlerException(Throwable e){
        Map<String,Object> map=new HashMap<>();
        //封装错误信息
        map.put("code",10086);
        map.put("mag",e.getMessage());
        return null;
    }
}
